<template>
	<view class="content-1-box">
		<view class="mt-30 font-24">
			<u-input v-model="describe" type="textarea" height="200" :border="false" placeholder="告诉我们,激励我们做得更好" />
			<view class="mt-24">
				<u-upload :action="action" :max-count="1" :header="header" :file-list="fileList" @on-remove="onRemove"
					@on-success="onSuccess"></u-upload>
			</view>
		</view>
		<view class="mx-32 py-60">
			<u-button type="warning" :custom-style="customStyle" @click="submit()">提交理由</u-button>
		</view>
	</view>
</template>

<script>
	import {
		baseUrl
	} from '@/common/request/baseurl.js';
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				customStyle: {
					backgroundColor: '#f0ad4e'
				},
				action: baseUrl + '/comFileDetail/uploadPublicFile',
				header: {
					publictoken: uni.getStorageSync('clinetToken')
				},
				describe: '',
				image: '',
			}
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			// 提交数据
			submit() {
				this.$u.api.addComFeedback({
					userId: this.userInfo.id,
					describe: this.describe,
					image: this.image
				}).then(res => {
					uni.showToast({
						title: '提交意见成功'
					})
					setTimeout(()=>{
						uni.navigateBack();
					},800)
				})
			},
			// 上传图片
			onSuccess(data, index, lists, name) {
				this.image = data.data;
			},
			// 删除图片
			onRemove(data) {
				this.image = ''
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #fff !important;
	}

	.content-1-box {
		background-color: #fff;
		border-radius: 16rpx;
		// padding: 30rpx;
		margin: 30rpx;

		.line {
			border-bottom: 1rpx solid #eaeaea;
			opacity: .3;
		}
	}

	.textarea_box {
		background-color: #f8f8f8;
	}

	.satisfied-box {
		background-color: #f8f8f8;
		padding: 8rpx 60rpx;
		border-radius: 16rpx;
	}

	.active {
		background-color: $uni-color-warning;
		color: #fff;
	}

	.is-current {
		background-color: $uni-color-warning !important;
		color: #ff007f !important;
	}

	::v-deep {
		.u-input__textarea {
			background-color: #f8f8f8;
			padding-left: 12rpx;
			padding-right: 12rpx;
			border-radius: 8rpx;
		}

		.uni-textarea-placeholder {
			color: #999 !important;
		}

		.u-star-wrap {
			margin-right: 12rpx;
		}
	}

	page {
		background: #f8f8f8;
	}

	.divider-box {
		margin: 0 120rpx;
	}
</style>